package com.apobates.forum.utils;

import java.time.ZoneId;
import java.util.stream.Stream;

/**
 * 以java.time.ZoneId的SHORT_IDS为参照
 *
 * @author xiaofanku
 * @since 20200609
 */
public enum DateTimeZoneEnum {
    ACT("Australia/Darwin"),
    AET("Australia/Sydney"),
    AGT("America/Argentina/Buenos_Aires"),
    ART("Africa/Cairo"),
    AST("America/Anchorage"),
    BET("America/Sao_Paulo"),
    BST("Asia/Dhaka"),
    CAT("Africa/Harare"),
    CNT("America/St_Johns"),
    CST("America/Chicago"),
    CTT("Asia/Shanghai"),
    EAT("Africa/Addis_Ababa"),
    ECT("Europe/Paris"),
    IET("America/Indiana/Indianapolis"),
    IST("Asia/Kolkata"),
    JST("Asia/Tokyo"),
    MIT("Pacific/Apia"),
    NET("Asia/Yerevan"),
    NST("Pacific/Auckland"),
    PLT("Asia/Karachi"),
    PNT("America/Phoenix"),
    PRT("America/Puerto_Rico"),
    PST("America/Los_Angeles"),
    SST("Pacific/Guadalcanal"),
    VST("Asia/Ho_Chi_Minh"),
    EST("-05:00"),
    MST("-07:00"),
    HST("-10:00");
    private final String zoneID;
    
    private DateTimeZoneEnum(String zoneID) {
        this.zoneID = zoneID;
    }
    
    public String getZoneID() {
        return zoneID;
    }
    
    public DateTimeZoneEnum of(String zoneID){
        return Stream.of(DateTimeZoneEnum.values()).filter(dt->dt.getZoneID().equals(zoneID)).findFirst().orElse(null);
    }
    
    public ZoneId toZone(){
        return ZoneId.of(this.getZoneID());
    }
}